package com.ecb.business.controller;

import com.ecb.business.dto.api.ApiResult;
import com.ecb.business.dto.chain.AddChainDTO;
import com.ecb.business.dto.chain.ChainNodeDTO;
import com.ecb.business.dto.chain.QueryChainDTO;
import com.ecb.business.service.ChainConfigManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("chainConfig")
@Api(tags = "区块链配置管理")
public class ChainConfigManageController {

    @Autowired
    ChainConfigManageService chainConfigManageService;

    @GetMapping("getAllChainConfig")
    @ApiOperation(value = "查询链配置信息",notes = "")
    public ApiResult getChainConfig(@RequestBody QueryChainDTO queryChainDTO){
        return ApiResult.T(chainConfigManageService.getChainConfig(queryChainDTO));
    }

    @PostMapping("addChain")
    @ApiOperation(value = "添加区块链",notes = "")
    public ApiResult queryContract(@RequestBody AddChainDTO addChainDTO ){
        return ApiResult.T(chainConfigManageService.addChainConfig(addChainDTO));
    }

    @PostMapping("updateChain")
    @ApiOperation(value = "更新区块链",notes = "")
    public ApiResult updateChain(@RequestBody AddChainDTO addChainDTO ){
        return ApiResult.T(chainConfigManageService.updateChainBaseInfo(addChainDTO));
    }
    @PostMapping("updateChainNode") // 更新链的节点
    @ApiOperation(value = "更新区块链的节点",notes = "")
    public ApiResult updateChain(@RequestBody ChainNodeDTO chainNodeDTO ){
        return ApiResult.T(chainConfigManageService.updateChainNode(chainNodeDTO));
    }
    @PostMapping("deleteChain")
    @ApiOperation(value = "删除区块链",notes = "")
    public ApiResult deleteChain(@RequestBody AddChainDTO addChainDTO  ){
        return ApiResult.T(chainConfigManageService.deleteChain(addChainDTO));
    }
}
